//
//  DBYInlandCollectionViewCell.m
//  MemoryTravel
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "DBYInlandCollectionViewCell.h"

@implementation DBYInlandCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubViews];
    }
    return self;
    
}

- (void)createSubViews
{
    
    self.image_urlImageView = [[UIImageView alloc]init];
    self.image_urlImageView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.image_urlImageView];
    [self.image_urlImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.and.left.mas_equalTo(0);
        make.size.equalTo(self.contentView);
        
        
    }];
    
    self.name_zh_cnLabel = [[UILabel alloc]init];
    self.name_zh_cnLabel.text = @"日本";
    self.name_zh_cnLabel.textColor = [UIColor whiteColor];
    self.name_zh_cnLabel.font = [UIFont systemFontOfSize:19];
    [self.contentView addSubview:self.name_zh_cnLabel];
    [self.name_zh_cnLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.left.equalTo(self.image_urlImageView.mas_left).offset(10);
        make.top.equalTo(self.image_urlImageView.mas_top).offset(10);
        make.size.mas_equalTo(CGSizeMake(160, 20));
    }];
    
    self.name_enLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.name_enLabel];
    self.name_enLabel.textColor = [UIColor whiteColor];
    self.name_enLabel.text = @"japan";
    
    [self.name_enLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.name_zh_cnLabel.mas_left);
        make.top.equalTo(self.name_zh_cnLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(160, 20));
        
    }];
    
    self.poi_countLabel = [[UILabel alloc]init];
    self.poi_countLabel.backgroundColor = [UIColor blackColor];
    self.poi_countLabel.text = @"旅行地 473";
    self.poi_countLabel.textAlignment = NSTextAlignmentCenter;
    self.poi_countLabel.font = [UIFont boldSystemFontOfSize:13];
    self.poi_countLabel.textColor = [UIColor whiteColor];
    self.poi_countLabel.alpha = 0.5;
    // 裁掉边框
    self.poi_countLabel.layer.masksToBounds = YES;
    // 设置椭圆形
    self.poi_countLabel.layer.cornerRadius = 10;
    
    [self.contentView addSubview:self.poi_countLabel];
    [self.poi_countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(30);
        make.top.equalTo(self.image_urlImageView.mas_bottom).offset(-30);
        make.size.mas_equalTo(CGSizeMake(100, 20));
    }];
    
    
}

-(void)setAModel:(WorldModel *)aModel
{
    if (_aModel != aModel) {
        
        _aModel = aModel;
        
    }
    
    
    self.name_zh_cnLabel.text = self.aModel.name_zh_cn;
    self.name_enLabel.text = self.aModel.name_en;
    
    NSString *count = [NSString stringWithFormat:@"旅行地 %@", self.aModel.poi_count];
    self.poi_countLabel.text = count;
    
    
    [self.image_urlImageView sd_setImageWithURL:[NSURL URLWithString:self.aModel.image_url] placeholderImage:[UIImage imageNamed:@"loading.jpg"]];
    
    
}

@end
